package mil.af.amc.adpetracker.web.actions.Organization;

import mil.af.amc.adpetracker.web.actions.AbstractAction;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForm;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Simple Action to change the organizationId in the session
 *
 * @author TSgt Jason Ferguson
 */

public class ChangeViewedOrganizationAction extends AbstractAction {

    private static final Log log = LogFactory.getLog(ChangeViewedOrganizationAction.class);

    @Override
    public ActionForward execute(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {

        int organizationId = Integer.parseInt(httpServletRequest.getParameter("organizationId"));
        httpServletRequest.getSession().setAttribute("organizationId", organizationId);

        return actionMapping.getInputForward();
    }
}
